#!/bin/sh

# this is an example used in the documentation in the 6 channel 
# xmlrpc receiver  example

# there brief explanations what each environemt variable does here, but
# please consult the telive manual: telive_doc.pdf
# sq5bpf

ulimit -c unlimited
export PATH=$PATH:/tetra/bin

# TETRA_OUTDIR - directory where to write the recorded ACELP voice files
# if unset defaults to /tetra/in
export TETRA_OUTDIR=/tetra/in

# TETRA_LOGFILE - filename where to write the log.
# if unset defaults to telive.log
export TETRA_LOGFILE=/tetra/log/telive.log

# TETRA_PORT - udp port where telive listens for communication from tetra-rx
# if unset defaults to 7379
export TETRA_PORT=7379

# TETRA_KEYS - if set, then telive behaves as if there keys are pressed at start
# if unset, nothing is done
#export TETRA_KEYS=lR #example: enable logging and recording
export TETRA_KEYS=m #enable mutessi

# TETRA_SSI_FILTER - a extended wildcard expression that determines which SSIs 
# are selected for playing live (if the filter is enabled)
# if unset, then no filter is used
#export TETRA_SSI_FILTER=1000 #example: match 1000
#export TETRA_SSI_FILTER=10?? #example: match 1000-1099
#export TETRA_SSI_FILTER='+(1000|[234]0??|?????)' #example: match 1000, 2000-2099, 3000-3099, 4000-4099, and any 5 digit number, you still have to enable the filter with f
# BIG FAT WARNING: if you're using a system without extended wildcard expressions  (like OSX), then you are left with standard wildcard expansion, the +(xxxx) will not work

# TETRA_KML_FILE - if set, the locations will be written periodically to this 
# file in KML format
export TETRA_KML_FILE=/tetra/log/tetra1.kml

# TETRA_KML_INTERVAL - this will set the maximum KML file refresh rate
# if unset, this will default to 30 seconds
export TETRA_KML_INTERVAL=3

# TETRA_SSI_DESCRIPTIONS - a file contaning textual descriptions of ssis
# if unset then no file is used
#export TETRA_SSI_DESCRIPTIONS=/tetra/ssi_descriptions

# TETRA_XMLFILE - a file containing descriptions of MCC and MNC
# if unset defaults to tetra.xml
# export TETRA_XMLFILE=tetra.xml

# TETRA_LOCK_FILE - lock file to use between multiple instances 
# of telive, so that they don't all play at the same time 
#export TETRA_LOCK_FILE=/tetra/telive_lock

#### optional receiver control via the gnuradio xmlrpc server ####

# TETRA_GR_XMLRPC_URL - url for the xmlrpc interface of the gnuradio receiver
# defaults to none (no receiver control)
export TETRA_GR_XMLRPC_URL=http://127.0.0.1:42000/

#### scanning stuff (you need to have the gnuradio xmlrpc receiver active) ####

# TETRA_SCAN_LIST - a list of frequency ranges to scan in the form:
# low frequency in MHz - high frequency in MHz / step in kHz, semicolon delimited, no spaces
# example: "390.2-390.3/12.5;420-420.8/12.5;425-425.8/12.5"
#export TETRA_SCAN_LIST="390-393/12.5;420-423/12.5;425-426.5/12.5" #local example
export TETRA_SCAN_LIST="390-395/12.5;420-430/12.5;870-876/12.5;450-470/12.5;915-921/12.5" #complete list (warning: very slow)

# TETRA_FREQLOGFILE - a file which will list every newly found frequency,
# with timestamp (useful when  scanning), if unset defaults to 
# telive_frequency.log
# export TETRA_FREQLOGFILE=telive_frequency.log

# TETRA_FREQUENCY_REPORT_FILE - a file where frequency info will be dumped
# when the d key is pressed, is unset defaults to telive_frequency_report.txt
# export TETRA_FREQUENCY_REPORT_FILE=telive_frequency_report.txt

# TETRA_RX_GAIN - the receiver gain to set at startup
# if unset, then the receiver gain is left as-is
# export TETRA_RX_GAIN=30

# TETRA_RX_PPM - the frequency correction coefficient in ppm
#  if unset, then the receiver ppm is left as-is
export TETRA_RX_PPM=10

# TETRA_AUTO_TUNE - tune unused channels from the info received from
# the network. 1 enables, 0 disables. is unset then 0 is assumed
export TETRA_AUTO_TUNE=1

# TETRA_RX_PPM_AUTOCORRECT - autocorrect the PPM  value from 
# received AFC data. 1 enables, 0 disables. is unset then 1 is assumed
export TETRA_RX_PPM_AUTOCORRECT=1

# TETRA_RX_BASEBAND_AUTOCORRECT - autocorrect the baseand frequency
# to try to  cover all requested frequencies
# 1 enables, 0 disables. is unset then 1 is assumed
export TETRA_RX_BASEBAND_AUTOCORRECT=1

# TETRA_RX_BASEBAND - the baseand frequency in MHz
export TETRA_RX_BASEBAND=391.100

# TETRA_RX_TUNE - semicolon delimited list of frequencies to tune the 
# receivers to, terminated by ; (also at the end)
# export TETRA_RX_TUNE="390.100;390,200;390,300;"

# internal tuning parameters, use at your own risk, the values shown are 
# defaults. if in doubt, RTFS
# if you don't know what you're doing, then don't touch these settings

# TETRA_REC_TIMEOUT - after how long we stop to record a usage identifier 
# value in seconds
#export TETRA_REC_TIMEOUT=30

# TETRA_SSI_TIMEOUT - after how long we forget SSIs
# value in seconds
#export TETRA_SSI_TIMEOUT=60

# TETRA_IDX_TIMEOUT -  after how long we disable the active flag
# value in seconds
#export TETRA_IDX_TIMEOUT=8

# TETRA_CURPLAYING_TIMEOUT - after how long we stop playing the current 
# usage identifier. value in seconds
#export TETRA_CURPLAYING_TIMEOUT=5

# TETRA_FREQ_TIMEOUT - after how long we forget frequency info
# if unset, this will default to 600 seconds. value in seconds
#export TETRA_FREQ_TIMEOUT=600

# TETRA_SCAN_TIMEOUT_SIGNAL - when scanning, how much to wait after 
# tuning in ms. defaults to 50
# export TETRA_SCAN_TIMEOUT_SIGNAL=50 

# TETRA_SCAN_TIMEOUT_BURST - when scanning, how much to wait for
# a BURST message in ms.  defaults to 300
# export TETRA_SCAN_TIMEOUT_BURST=300

# TETRA_SCAN_TIMEOUT_SYSINFO - when scanning, how much to wait for
# a SYSINFO message in ms.  defaults to 2000
# export TETRA_SCAN_TIMEOUT_SYSINFO=2000

./telive

